import { createApp } from "vue";
import pinia from "./stores";
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import "element-plus/dist/index.css";
import App from "./App.vue";
import router from "./router";
import "./styles/index.scss";
import ElSvg from "./components/SvgIcon/ElSvg";
import "./permission";
import { useUserInfoStore } from "@/stores/userInfo";
//引入三级联动组件
import Category from "@/components/Category/index.vue";
import "@/mockServer";
import { VueEcharts } from "@/plugins/echarts";
const app = createApp(App);

const userInfo = useUserInfoStore();
app.directive("has", (el, binding) => {
  if (!userInfo.userInfo.buttons.includes(binding.value)) {
    el.remove();
  }
});
ElSvg(app);
//将三级联动组件全局注册
app.component("Category", Category);

app
  .use(pinia)
  .use(router)
  .use(VueEcharts)
  .use(ElementPlus, {
    locale: zhCn,
  })
  .mount("#app");
